DECLARE @my_var INT;
DECLARE @my_var INT = 10;
DECLARE @my_var1 INT, @my_var2 NVARCHAR(50), @my_var3 DATE;
DECLARE my_var INT DEFAULT 10;
DECLARE `order_cursor` FOR SELECT * FROM orders;
DECLARE cur CURSOR FOR SELECT id FROM test;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;  -- 当没有更多数据时设置done = 1
DECLARE CONTINUE HANDLER FOR SQLSTATE '23000' SET duplicate_key = 1;  -- 当遇到重复键时设置duplicate_key = 1
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET error_occurred = 1;  -- 当任意SQL异常发生时设置error_occurred = 1
DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_rows = 1;  --当查询结果为空设置no_rows = 1
DECLARE CONTINUE HANDLER FOR SQLWARNING SET warning_occurred = 1;  --当SQL警告发生时设置warning_occurred = 1

IF @color = 'red' THEN 
    PRINT 'The color is red.'; 
ELSE
    PRINT 'The color is not red.';
END IF;